<%@page import="com.sun.org.apache.xerces.internal.impl.dv.util.Base64"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="dlgUpdateImage" style="display: none;">
	<div style="padding: 20px 20px 5px;">
		<form id="updateFile" enctype="multipart/form-data">
		  File: <input type="file" name="myFile"/>
		  <input type="submit" value="Update" style="float: right;height: 24px">
		</form>
	</div>
</div>
<script type="text/javascript">
	var formURL = '${pageContext.request.contextPath}/auth/uploadImage';
	//$('#imageShow').attr('src',formURL);
	function dialogUpdateImage(){
		$('#dlgUpdateImage').attr("style","display:block");
	    $('#dlgUpdateImage').dialog({
	        title:' Update Image', width:400,height:100,modal:true
	    });
	}
	$("#updateFile").submit(function(e) {
		var formData = new FormData($("#updateFile")[0]);	
     	$.ajax({
     		url : formURL,
     		data : formData,
	       	type : "POST",
	       	async: false,
            cache: false,
            contentType: false,
            processData: false,
	      	success : function(result) {
	      		$('#imageShow').attr('src','data:image/png;base64,'+result);
	      		$('input[name=image]').val(result);
	      		$('#dlgUpdateImage').dialog('close');
	       	},
	       	error : function(result){
	           alert('error'+JSON.stringify(result));
	       	}
     	});  
     	e.preventDefault(); 
     	
     	return false;
    });	
	
</script>
